%{

#include "gen-record.tab.h"
#include "member_type.h"
#include <string.h>

%}

dec_number 0|[1-9][0-9]*
hex_number 0x[[:xdigit:]]*
oct_number 0[0-7]*

white_space [ \t\n]*
indent \ \ 
semicolon ;

record record

integer_type u?int(8|16|32|64)_t
integer_value (\+|-)?({oct_number}|{dec_number}|{hex_number})

string_type string
string_value \".*\"

identifier [[:alpha:]][[:alnum:]_]*

obrace \{
cbrace \}

%%

{integer_type} {
	yylval.type_ = new MemberType;
	yylval.type_->set_id(MemberType::INTEGER_T);
	yylval.type_->set_name(strdup(yytext));
	return PRIMITIVE_TYPE;
}

{string_type} {
	char* name  = (char*)malloc(strlen(yytext)+5);
	strcpy(name, "std::");
	strcat(name, yytext);

	yylval.type_ = new MemberType;
	yylval.type_->set_id(MemberType::STRING_T);
	yylval.type_->set_name(name);
	yylval.type_->set_reference(true);
	return PRIMITIVE_TYPE;
}

{record} return RECORD;

{semicolon} return SEMICOLON;

{obrace} return OBRACE;
{cbrace} return CBRACE;

{identifier} {
	yylval.string_ = strdup(yytext);
	return IDENTIFIER;
}

{white_space} {
}



%%
